package com.qk.management.service.impl;

import com.qk.constant.CacheConstant;
import com.qk.management.annotation.RedisCacheable;
import com.qk.management.mapper.BusinessMapper;
import com.qk.management.mapper.ClueMapper;
import com.qk.management.service.ReportService;
import com.qk.vo.home.OverviewVO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
@RequiredArgsConstructor
public class ReportServiceImpl implements ReportService {

    private final ClueMapper clueMapper;

    private final BusinessMapper businessMapper;

    @Override
    @RedisCacheable(prefix = CacheConstant.CACHE_PREFIX_PORTAL,expire=5,expireTimeFormat= TimeUnit.MINUTES)
    public OverviewVO getOverview() {
        OverviewVO clueOverviewVO = clueMapper.getClueOverviewData();
        OverviewVO businessOverviewVO = businessMapper.getBusinessOverviewData();
        BeanUtils.copyProperties(businessOverviewVO, clueOverviewVO, "clueTotal", "clueWaitAllot", "clueWaitFollow", "clueFollowing", "clueFalse", "clueConvertBusiness");
        return clueOverviewVO;
    }
}